import Vue from 'vue'
import axios from 'axios'


export const global={
  loadsound: function(url) {
      // var con = new AudioContext();
      let AudioContext = window.AudioContext || window.webkitAudioContext;
      let audioCtx = AudioContext ? new AudioContext() : '';
      axios.get(url, { responseType: "arraybuffer" }).then(req => {  
        audioCtx.decodeAudioData(
          req.data,
          function(buffer) {  
            console.log(11111111)      
            var source = audioCtx.createBufferSource();
            source.buffer = buffer;
            source.connect(audioCtx.destination);
            source.start(0);

          },
          function(e) {
            console.info("错误");
          }
        );
      });
    }
  
}
